package com.example.demo.huawei;
//https://blog.csdn.net/banxia_frontend/article/details/134430737

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * 整数表示为 连续自然数之和
 * 输入目标整数
 * 输出：
 * 输入：9
 * 输出：
 * 9=9
 * 9=4+5
 * 9=2+3+4
 * Result:3
 * <p>
 * 注意：个数最少的优先输出
 * 每个表达式按照递增顺序输出
 * 每个测试数据结束 输出一个 Result:x
 * x表示表达式的个数
 */
public class Main_19 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int target = Integer.parseInt(s);


        // 9 8 7 6 5 4 3 2 1组成数组
        //        int[] arr = new int[target];
        //        for (int i = target; i >= 1; i--) {
        //            arr[target - i] = i;
        //        }
        find2(target);
    }

    //   target=9 组成数组1 2 3 4 5 6 7 8 9
    private static void find(int target) {
        List<String> result = new ArrayList<>();
        String common = target + "=";
        for (int i = 0; i <= target; i++) {
            int sum = 0;
            StringBuilder sb2 = new StringBuilder();
            for (int j = i + 1; j <= target; j++) {
                sum += j;
                if (sb2.length() > 0) {
                    sb2.append("+");
                }
                sb2.append(j);
                if (sum == target) {
                    result.add(sb2.toString());
                    break;
                } else if (sum > target) {
                    break;
                }
            }
        }
        for (int r = result.size() - 1; r >= 0; r--) {
            System.out.println(common + result.get(r));
        }
        System.out.println("Result:" + result.size());
    }

    /**
     * 2024-06-24 16:23:59
     *
     * @param target
     */

    //target=9 组成数组1 2 3 4 5 6 7 8 9
    private static void find2(int target) {
        List<String> result = new ArrayList<>();
        for (int i = 1; i <= target; i++) {
            int sum = 0;
            StringBuilder sb = new StringBuilder();
            sb.append(target).append("=");
            sb.append(i);
            for (int j = i + 1; j <= target; j++) {
                sum = sum + j;
                sb.append("+").append(j);
                if (sum == target - i) {
                    result.add(sb.toString());
                    break;
                }
            }
        }
        StringBuilder sb2 = new StringBuilder();
        result.add(sb2.append(target).append("=").append(target).toString());
        for (int r = result.size() - 1; r >= 0; r--) {
            System.out.println(result.get(r));
        }
        System.out.println("Result:" + result.size());
    }
}
